app.controller('vipMessageNamePageCtrl',function($scope,$state,PopupService,$stateParams,$http,$myconfig,$timeout,$ionicConfig){

    $scope.users = JSON.parse(localStorage.getItem('user'));

    if(!$scope.users){
        $scope.err = '请登录您的账户后重试';
        return;
    }

    // 保存修改的姓名
    $scope.saveName = function(){
        $http.post($myconfig.api.base_host + '/users/update_one_user',{
            "mobile":$scope.users.mobile,
	        "username":$scope.users.username,
        }).then(function(res){
            if(res.data.success){
                localStorage.setItem('user',JSON.stringify($scope.users));
                $state.go('app.vip_message');
            }else{
                $scope.err = res.data.data;
            }
        });
    };
    // 清空输入框内容
    $scope.clearMEs = function(){
        $scope.users.username = '';
    };

    $scope.$on('$ionicView.enter', function(){

        $ionicConfig.views.swipeBackEnabled(false);

    });

});
